<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
GenericEntity (jersey-bundle 1.9 API)
</TITLE>


<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="GenericEntity (jersey-bundle 1.9 API)";
    }
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">
<HR>


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/GenericEntity.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../javax/ws/rs/core/EntityTag.html" title="class in javax.ws.rs.core"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../javax/ws/rs/core/HttpHeaders.html" title="interface in javax.ws.rs.core"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?javax/ws/rs/core/GenericEntity.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="GenericEntity.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.ws.rs.core</FONT>
<BR>
Class GenericEntity&lt;T&gt;</H2>
<PRE>
java.lang.Object
  <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>javax.ws.rs.core.GenericEntity&lt;T&gt;</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>GenericEntity&lt;T&gt;</B><DT>extends java.lang.Object</DL>
</PRE>

<P>
Represents a response entity of a generic type <code>T</code>.
 
 <p>Normally type erasure removes generic type information such that a
 <A HREF="../../../../javax/ws/rs/core/Response.html" title="class in javax.ws.rs.core"><CODE>Response</CODE></A> instance that contains, e.g., an entity of type
 <code>List&lt;String&gt;</code> appears to contain a raw <code>List&lt;?&gt;</code> at runtime.
 When the generic type is required to select a suitable
 <A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="interface in javax.ws.rs.ext"><CODE>MessageBodyWriter</CODE></A>, this class may be used to wrap the entity and
 capture its generic type.</p>
 
 <p>There are two ways to create an instance:</p>
 <ol>
 <li>Create a (typically anonymous) subclass of this 
 class which enables retrieval of the type information at runtime despite 
 type erasure. For example, the following code shows how to create a
 <A HREF="../../../../javax/ws/rs/core/Response.html" title="class in javax.ws.rs.core"><CODE>Response</CODE></A> containing an entity of type <code>List&lt;String&gt;</code> whose
 generic type will be available at runtime for selection of a suitable
 <A HREF="../../../../javax/ws/rs/ext/MessageBodyWriter.html" title="interface in javax.ws.rs.ext"><CODE>MessageBodyWriter</CODE></A>:
 
 <pre>List&lt;String&gt; list = new ArrayList&lt;String&gt;();
GenericEntity&lt;List&lt;String&gt;&gt; entity = new GenericEntity&lt;List&lt;String&gt;&gt;(list) {};
Response response = Response.ok(entity).build();</pre>

 <p>where <code>list</code> is the instance of <code>List&lt;String&gt</code>
 that will form the response body and entity is an instance of an anonymous
 subclass of <code>GenericEntity</code>.</p></li>
 <li>Create an instance directly by supplying the generic type information
 with the entity. For example the following code shows how to create
 a response containing the result of a method invoked via reflection:
 <pre>Method method = ...;
GenericEntity&lt;Object&gt; entity = new GenericEntity&lt;Object&gt;(
    method.invoke(...), method.getGenericReturnType());
Response response = Response.ok(entity).build();</pre></li>
 <p>The above obtains the generic type from the return type of the method,
 the raw type is the class of entity.</p> 
 </ol>
<P>

<P>
<HR>

<P>

<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected </CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/core/GenericEntity.html#GenericEntity(T)">GenericEntity</A></B>(<A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</A>&nbsp;entity)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a new generic entity.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/core/GenericEntity.html#GenericEntity(T, java.lang.reflect.Type)">GenericEntity</A></B>(<A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</A>&nbsp;entity,
              java.lang.reflect.Type&nbsp;genericType)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a new instance of GenericEntity, supplying the generic type
 information.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/core/GenericEntity.html#getEntity()">getEntity</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the enclosed entity</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.Class&lt;?&gt;</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/core/GenericEntity.html#getRawType()">getRawType</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the raw type of the enclosed entity.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.reflect.Type</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../javax/ws/rs/core/GenericEntity.html#getType()">getType</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets underlying <code>Type</code> instance.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ========= CONSTRUCTOR DETAIL ======== -->

<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="GenericEntity(java.lang.Object)"><!-- --></A><A NAME="GenericEntity(T)"><!-- --></A><H3>
GenericEntity</H3>
<PRE>
protected <B>GenericEntity</B>(<A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</A>&nbsp;entity)</PRE>
<DL>
<DD>Constructs a new generic entity. Derives represented class from type
 parameter. Note that this constructor is protected, users should create
 a (usually anonymous) subclass as shown above.
<P>
<DL>
<DT><B>Parameters:</B><DD><CODE>entity</CODE> - the entity instance, must not be null
<DT><B>Throws:</B>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if entity is null</DL>
</DL>
<HR>

<A NAME="GenericEntity(java.lang.Object,java.lang.reflect.Type)"><!-- --></A><A NAME="GenericEntity(T, java.lang.reflect.Type)"><!-- --></A><H3>
GenericEntity</H3>
<PRE>
public <B>GenericEntity</B>(<A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</A>&nbsp;entity,
                     java.lang.reflect.Type&nbsp;genericType)</PRE>
<DL>
<DD>Create a new instance of GenericEntity, supplying the generic type
 information. The entity must be assignable to a variable of the
 supplied generic type, e.g. if <code>entity</code> is an instance of
 <code>ArrayList&lt;String&gt;</code> then <code>genericType</code> could
 be the same or a superclass of <code>ArrayList</code> with the same generic
 type like <code>List&lt;String&gt;</code>.
<P>
<DL>
<DT><B>Parameters:</B><DD><CODE>entity</CODE> - the entity instance, must not be null<DD><CODE>genericType</CODE> - the generic type, must not be null
<DT><B>Throws:</B>
<DD><CODE>java.lang.IllegalArgumentException</CODE> - if the entity is not assignable to
 a variable of the supplied generic type or if entity or genericType
 is null.</DL>
</DL>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="getRawType()"><!-- --></A><H3>
getRawType</H3>
<PRE>
public final java.lang.Class&lt;?&gt; <B>getRawType</B>()</PRE>
<DL>
<DD>Gets the raw type of the enclosed entity. Note that this is the raw type of
 the instance, not the raw type of the type parameter. I.e. in the example
 in the introduction, the raw type is <code>ArrayList</code> not <code>List</code>.
<P>
<DD><DL>

<DT><B>Returns:</B><DD>the raw type</DL>
</DD>
</DL>
<HR>

<A NAME="getType()"><!-- --></A><H3>
getType</H3>
<PRE>
public final java.lang.reflect.Type <B>getType</B>()</PRE>
<DL>
<DD>Gets underlying <code>Type</code> instance. Note that this is derived from the
 type parameter, not the enclosed instance. I.e. in the example
 in the introduction, the type is <code>List&lt;String&gt;</code> not
 <code>ArrayList&lt;String&gt;</code>.
<P>
<DD><DL>

<DT><B>Returns:</B><DD>the type</DL>
</DD>
</DL>
<HR>

<A NAME="getEntity()"><!-- --></A><H3>
getEntity</H3>
<PRE>
public final <A HREF="../../../../javax/ws/rs/core/GenericEntity.html" title="type parameter in GenericEntity">T</A> <B>getEntity</B>()</PRE>
<DL>
<DD>Get the enclosed entity
<P>
<DD><DL>

<DT><B>Returns:</B><DD>the enclosed entity</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/GenericEntity.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../javax/ws/rs/core/EntityTag.html" title="class in javax.ws.rs.core"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../javax/ws/rs/core/HttpHeaders.html" title="interface in javax.ws.rs.core"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?javax/ws/rs/core/GenericEntity.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="GenericEntity.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>
Copyright &#169; 2011 <a href="http://www.oracle.com/">Oracle Corporation</a>. All Rights Reserved.
</BODY>
</HTML>
